home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8375 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  59 lines

  1. Path: news2.EUnet.fr!enst!orfanos
  2. From: orfanos@ima.enst.fr
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Stack Fault Error message
  5. Date: 17 Feb 1996 11:05:14 GMT
  6. Organization: ENST - France
  7. Sender: orfanos@news.enst.fr (Dimitri Papadopoulos Orfanos)
  8. Distribution: world
  9. Message-ID: <4g4cpa$m65@enst.enst.fr>
  10. References: <4g3dg2$rsu@ixnews3.ix.netcom.com>
  11. NNTP-Posting-Host: mathieu-2.enst.fr
  12. Mime-Version: 1.0
  13. Content-Type: text/plain; charset=iso-8859-1
  14. Content-Transfer-Encoding: 8bit
  15.  
  16.  
  17. In article <4g3dg2$rsu@ixnews3.ix.netcom.com>,
  18. rgd@ix.netcom.com (Raymond Dykeman) writes:
  19. > I am using Borland Turbo C++ 3.0 and am getting Stack Fault
  20. > error and "Undefined" error messages.  I presume this is
  21. > because I am running low on memory.  Can someone confirm/deny
  22. > this. If so can you reccomend # megs needed.
  23.  
  24. This has _nothing_ to do with MB of memory available on your
  25. hardware. DOS will only use 640 kB of them anyway.
  26.  
  27. On DOS, stack is limited to one segment (64 kB) in Large,
  28. Medium and Huge models. It is even smaller in Small, Compact
  29. and Tiny models. Default stack size is pretty small: 4 kB.
  30. You can increase it up to 64 kB:
  31.  
  32.     extern unsigned _stklen = 40000; // size in bytes
  33.     
  34.     int main() {
  35.         // ...
  36.     }
  37.  
  38. If you want more stack than 64 kB, you'll have to buy a
  39. DOS-Extender (I use PowerPack from Borland), or use another
  40. environment (Windows 95 and NT, OS/2, Unix, etc.).
  41.  
  42. If these aren't options, try using less stack: make big
  43. automatic variables (arrays in functions, etc.) static:
  44.  
  45.     void f() {
  46.         int table[10000];
  47.         // ...
  48.     }
  49.  
  50. should be rewritten as:
  51.  
  52.     void f() {
  53.         static int table[10000];
  54.         // ...
  55.     }
  56.  
  57. Thus, these variables will be moved from stack segment to data
  58. segements.
  59.